

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/resource/img/favicon.png">
  <link rel="icon" type="image/png" href="/resource/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="soldier">
  <meta name="keywords" content="">
  <title>Travis-ci+Hexo+GithubPages搭建个人博客 - 黄结的个人博客</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>soldier</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" href="/about/">
                    
                    个人简历
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://soldiergit.github.io/honor/">
                    
                    项目及获奖
                  </a>
                
              </div>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-05-12 16:05" pubdate>
        2021年5月12日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.7k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      26
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">Travis-ci+Hexo+GithubPages搭建个人博客</h1>
            
            <div class="markdown-body" id="post-body">
              <h2 id="1-本地搭建博客框架"><a href="#1-本地搭建博客框架" class="headerlink" title="1.本地搭建博客框架"></a>1.本地搭建博客框架</h2><ol>
<li><p>安装node.js，最好是10这个版本的</p>
<ol>
<li><p>windows10下<br>链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1gS0UEbEeicHlMaXUe-pgYw">https://pan.baidu.com/s/1gS0UEbEeicHlMaXUe-pgYw</a>  提取码：4n2c </p>
</li>
<li><p>Ubuntu下：</p>
<pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 更新软件 </span>
sudo apt remove --purge nodejs npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove
<span class="hljs-meta">#</span><span class="bash"> 安装</span>
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
sudo apt-get update &amp;&amp; sudo apt-get install yarn</code></pre>
</li>
<li><p>npm换源</p>
<pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> npm换源</span>
npm config set registry https://registry.npm.taobao.org
<span class="hljs-meta">#</span><span class="bash">如果只是临时改变源，可以这样</span>
npm --registry=https://registry.npm.taobao.org
<span class="hljs-meta">#</span><span class="bash"> 更新</span>
npm install -g npm</code></pre>
</li>
</ol>
</li>
<li><p>创建博客</p>
<pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 全局安装hexo</span>
npm install hexo-cli -g
<span class="hljs-meta">#</span><span class="bash"> 创建项目</span>
hexo init Github用户名.github.io
<span class="hljs-meta">#</span><span class="bash"> 安装依赖</span>
npm install
<span class="hljs-meta">#</span><span class="bash"> 安装主题（去Hexo官网选择自己喜欢的博客主题）</span>
npm install --save hexo-theme-fluid
<span class="hljs-meta">#</span><span class="bash"> 启动项目</span>
npm run server
<span class="hljs-meta">#</span><span class="bash"> 访问http://localhost:4000查看效果</span></code></pre>

</li>
</ol>
<h2 id="2-Github配置"><a href="#2-Github配置" class="headerlink" title="2.Github配置"></a>2.Github配置</h2><ol>
<li><p>创建一个<code>用户名.github.io</code>的public类型的仓库，不要新建Readme.md文件</p>
</li>
<li><p>创建Github访问令牌：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/soldier-cnblogs/p/13386848.html">教程</a></p>
</li>
<li><p>创建一个<code>resource</code>分支，将其设置为主分支<br><img src="/resource/img/ci/T_GithubPages_1.png" srcset="/img/loading.gif" alt="img"></p>
</li>
<li><p><del>手动部署项目</del></p>
<ol>
<li><p>先提交一次到Github</p>
<pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 在项目根目录初始化</span>
git init
<span class="hljs-meta">#</span><span class="bash"> 设置远程仓库</span>
git remote add origin https://github.com/soldiergit/soldiergit.github.io.git
<span class="hljs-meta">#</span><span class="bash"> 添加</span>
git add .
<span class="hljs-meta">#</span><span class="bash"> 提交信息</span>
git commit -m &#x27;init commit&#x27;
<span class="hljs-meta">#</span><span class="bash"> 提交项目(注意这个分支是源码分支，不是GithubPages页面分支-是master)</span>
git push origin resource</code></pre>
</li>
<li><p>配置<code> _config.yml</code></p>
<pre><code class="hljs yml"><span class="hljs-attr">deploy:</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">type:</span> <span class="hljs-string">git</span>
<span class="hljs-comment"># 部署到的仓库</span>
  <span class="hljs-attr">repo:</span> <span class="hljs-string">https://github.com/soldiergit/soldiergit.github.io</span>
<span class="hljs-comment"># 部署到的分支(GithubPages页面分)</span>
  <span class="hljs-attr">branch:</span> <span class="hljs-string">master</span></code></pre>
</li>
<li><p>部署</p>
<pre><code class="hljs shell"><span class="hljs-meta">#</span><span class="bash"> 项目根目录输入</span>
hexo deploy
<span class="hljs-meta">#</span><span class="bash"> 输入GitHub用户名密码即可完成部署</span></code></pre>

</li>
</ol>
</li>
</ol>
<h2 id="3-Travis-ci配置"><a href="#3-Travis-ci配置" class="headerlink" title="3.Travis-ci配置"></a>3.Travis-ci配置</h2><ol>
<li>使用github账号授权登录 <a target="_blank" rel="noopener" href="https://travis-ci.org/">Travis-ci官网</a> ，点击Sign In</li>
<li>在官网build<code>用户名.github.io</code>项目<br>点击这里的“+”号<br><img src="/resource/img/ci/T_GithubPages_2.png" srcset="/img/loading.gif" alt="img"><br>找到或搜索我们的项目<br><img src="/resource/img/ci/T_GithubPages_3.png" srcset="/img/loading.gif" alt="img"><br>完成之后可以在首页见到该项目<br><img src="/resource/img/ci/T_GithubPages_4.png" srcset="/img/loading.gif" alt="img"></li>
<li>进入该项目，点击右侧的<code>More options</code>选择<code>Settings</code><br>在<code>Environment Variables</code>下 add 一个名为<code>Github_Token</code>的变量<br><img src="/resource/img/ci/T_GithubPages_5.png" srcset="/img/loading.gif" alt="img"></li>
</ol>
<p>4.提交代码到Github</p>
<ol>
<li><p>在本地项目的根目录下新建一个<code>.travis.yml</code>文件</p>
<details>
  <summary>点击展开</summary>

<pre><code class="hljs yml"><span class="hljs-comment"># 设置语言</span>
<span class="hljs-attr">language:</span> <span class="hljs-string">node_js</span>

<span class="hljs-comment"># 设置相应的版本</span>
<span class="hljs-attr">node_js:</span> <span class="hljs-string">stable</span>

<span class="hljs-attr">cache:</span>
  <span class="hljs-attr">apt:</span> <span class="hljs-literal">true</span>
  <span class="hljs-attr">directories:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">node_modules</span> <span class="hljs-comment"># 缓存不经常更改的内容</span>

<span class="hljs-comment"># 更改时区</span>
<span class="hljs-attr">before_install:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">TZ=&#x27;Asia/Shanghai&#x27;</span>

<span class="hljs-comment"># 安装hexo及插件</span>
<span class="hljs-attr">install:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">npm</span> <span class="hljs-string">install</span>

<span class="hljs-comment"># 下拉代码后执行的操作</span>
<span class="hljs-attr">script:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">hexo</span> <span class="hljs-string">clean</span> <span class="hljs-comment"># 清除</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">hexo</span> <span class="hljs-string">g</span> <span class="hljs-comment"># 生成</span>

<span class="hljs-attr">after_script:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">cd</span> <span class="hljs-string">./public</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">init</span>
  <span class="hljs-comment"># 修改github的用户名</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">user.name</span> <span class="hljs-string">&quot;soldiergit&quot;</span>
  <span class="hljs-comment"># 修改email</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">user.email</span> <span class="hljs-string">&quot;soldier_wyyx@163.com&quot;</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">add</span> <span class="hljs-string">.</span>
  <span class="hljs-comment"># 提交记录包含时间 跟上面更改时区配合</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">commit</span> <span class="hljs-string">-m</span> <span class="hljs-string">&quot;Travis CI Auto Builder at `date +&quot;</span><span class="hljs-string">%Y-%m-%d</span> <span class="hljs-string">%H:%M&quot;`&quot;</span>
  <span class="hljs-comment"># Travis_Token是在Travis官网中配置环境变量的名称（more options 选择 setting添加的值）</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">--force</span> <span class="hljs-string">--quiet</span> <span class="hljs-string">&quot;https://$&#123;Github_Token&#125;@$&#123;GH_REF&#125;&quot;</span> <span class="hljs-string">master:master</span>

<span class="hljs-comment"># 只监测resource分支，resource是我存放源码的分支的名称，可根据自己情况设置</span>
<span class="hljs-attr">branches:</span>
  <span class="hljs-attr">only:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">resource</span>

<span class="hljs-comment"># 配置常量</span>
<span class="hljs-attr">env:</span>
  <span class="hljs-attr">global:</span>
    <span class="hljs-comment"># 设置GH_REF，注意更改yourname及末尾加上.git</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">GH_REF:</span> <span class="hljs-string">github.com/soldiergit/soldiergit.github.io.git</span>

<span class="hljs-comment"># 配置通知（电子邮件、IRC、campfire等）</span>
<span class="hljs-comment"># https://docs.travis-ci.com/user/notifications/</span>
<span class="hljs-attr">notifications:</span>
  <span class="hljs-attr">email:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-number">583403411</span><span class="hljs-string">@qq.com</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">soldier_wyyx@163.com</span>
  <span class="hljs-attr">on_success:</span> <span class="hljs-string">change</span>
  <span class="hljs-attr">on_failure:</span> <span class="hljs-string">always</span></code></pre>
 </details>

<p><img src="/resource/img/ci/T_GithubPages_6.png" srcset="/img/loading.gif" alt="img"></p>
</li>
<li><p>将所有代码提交到Github的<code>resource</code>上即可<br><img src="/resource/img/ci/T_GithubPages_7.png" srcset="/img/loading.gif" alt="img"><br><img src="/resource/img/ci/T_GithubPages_8.png" srcset="/img/loading.gif" alt="img"><br><img src="/resource/img/ci/T_GithubPages_9.png" srcset="/img/loading.gif" alt="img"></p>
</li>
</ol>
<h2 id="4-实现在线写作"><a href="#4-实现在线写作" class="headerlink" title="4.实现在线写作"></a>4.实现在线写作</h2><h3 id="实现思路"><a href="#实现思路" class="headerlink" title="实现思路"></a>实现思路</h3><p><img src="/resource/img/ci/silu.png" srcset="/img/loading.gif" alt="img"></p>
<h3 id="实现步骤"><a href="#实现步骤" class="headerlink" title="实现步骤"></a>实现步骤</h3><ol>
<li><p>获取 <a target="_blank" rel="noopener" href="https://travis-ci.org/account/preferences">Travis-ci</a> 的访问 token<br> <img src="/resource/img/ci/travisci_token.png" srcset="/img/loading.gif" alt="img"></p>
</li>
<li><p>编写触发 Travis-ci 的 Serverless 函数：注册<a target="_blank" rel="noopener" href="https://cloud.tencent.com/">腾讯云</a> 并边<a target="_blank" rel="noopener" href="https://console.cloud.tencent.com/scf/list">创建一个云函数</a><br> <img src="/resource/img/ci/serverless.png" srcset="/img/loading.gif" alt="img"></p>
 <pre><code class="hljs py"><span class="hljs-comment"># -*- coding: utf8 -*-</span>
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> json
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main_handler</span>(<span class="hljs-params">event, context</span>):</span>
    r = requests.post(<span class="hljs-string">&quot;https://api.travis-ci.org/repo/soldiergit%2Fsoldiergit.github.io/requests&quot;</span>,
    json = &#123;<span class="hljs-string">&quot;request&quot;</span>: &#123;<span class="hljs-string">&quot;branch&quot;</span>: <span class="hljs-string">&quot;src&quot;</span>&#125;&#125;,
    headers = &#123;<span class="hljs-string">&quot;User-Agent&quot;</span>:<span class="hljs-string">&#x27;curl/7.52.1&#x27;</span>,
              <span class="hljs-string">&#x27;Content-Type&#x27;</span>: <span class="hljs-string">&#x27;application/json&#x27;</span>,
              <span class="hljs-string">&#x27;Travis-API-Version&#x27;</span>: <span class="hljs-string">&#x27;3&#x27;</span>,
              <span class="hljs-string">&#x27;Accept&#x27;</span>: <span class="hljs-string">&#x27;application/json&#x27;</span>,
              <span class="hljs-string">&#x27;Authorization&#x27;</span>: <span class="hljs-string">&#x27;travis-ci的token&#x27;</span>&#125;)
    <span class="hljs-keyword">if</span> r.status_code == <span class="hljs-number">204</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;This&#x27;s OK!&quot;</span> 
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> r.status_code</code></pre>
</li>
<li><p>创建触发器，将函数发布，复制该函数的访问地址<br> <img src="/resource/img/ci/trigger.png" srcset="/img/loading.gif" alt="img"></p>
</li>
<li><p>配置语雀</p>
<ol>
<li>注册语雀账号，创建一个<code>文档知识库</code>，专门为GithubPages服务</li>
<li>配置语雀 webhook，将上一步复制的函数访问地址贴到 URL 那栏<br> <img src="/resource/img/ci/yuque1.png" srcset="/img/loading.gif" alt="img"></li>
<li>创建一个<a target="_blank" rel="noopener" href="https://www.yuque.com/settings/tokens">语雀Token</a>，勾选<code>读取</code></li>
</ol>
</li>
<li><p>项目配置</p>
<ol>
<li><p>安装插件</p>
<pre><code class="hljs shell">npm i -g yuque-hexo</code></pre></li>
<li><p>配置 package.json<br> <img src="/resource/img/ci/yuque2.png" srcset="/img/loading.gif" alt="img"></p>
 <pre><code class="hljs json">&#123;
  <span class="hljs-attr">&quot;name&quot;</span>: <span class="hljs-string">&quot;hexo-site&quot;</span>,
  <span class="hljs-attr">&quot;version&quot;</span>: <span class="hljs-string">&quot;0.0.0&quot;</span>,
  <span class="hljs-attr">&quot;private&quot;</span>: <span class="hljs-literal">true</span>,
  <span class="hljs-attr">&quot;scripts&quot;</span>: &#123;
    <span class="hljs-attr">&quot;sync&quot;</span>: <span class="hljs-string">&quot;yuque-hexo sync&quot;</span>,
    <span class="hljs-attr">&quot;clean:yuque&quot;</span>: <span class="hljs-string">&quot;yuque-hexo clean&quot;</span>,
    <span class="hljs-attr">&quot;build&quot;</span>: <span class="hljs-string">&quot;hexo generate&quot;</span>,
    <span class="hljs-attr">&quot;clean&quot;</span>: <span class="hljs-string">&quot;hexo clean&quot;</span>,
    <span class="hljs-attr">&quot;deploy&quot;</span>: <span class="hljs-string">&quot;hexo deploy&quot;</span>,
    <span class="hljs-attr">&quot;server&quot;</span>: <span class="hljs-string">&quot;hexo server&quot;</span>
  &#125;,
  <span class="hljs-attr">&quot;hexo&quot;</span>: &#123;
    <span class="hljs-attr">&quot;version&quot;</span>: <span class="hljs-string">&quot;5.2.0&quot;</span>
  &#125;,
  <span class="hljs-attr">&quot;yuqueConfig&quot;</span>: &#123;
  <span class="hljs-attr">&quot;postPath&quot;</span>: <span class="hljs-string">&quot;source/_posts/yuque&quot;</span>,
  <span class="hljs-attr">&quot;cachePath&quot;</span>: <span class="hljs-string">&quot;yuque.json&quot;</span>,
  <span class="hljs-attr">&quot;mdNameFormat&quot;</span>: <span class="hljs-string">&quot;slug&quot;</span>,
  <span class="hljs-attr">&quot;adapter&quot;</span>: <span class="hljs-string">&quot;hexo&quot;</span>,
  <span class="hljs-attr">&quot;concurrency&quot;</span>: <span class="hljs-number">5</span>,
  <span class="hljs-attr">&quot;baseUrl&quot;</span>: <span class="hljs-string">&quot;https://www.yuque.com/api/v2&quot;</span>,
  <span class="hljs-attr">&quot;login&quot;</span>: <span class="hljs-string">&quot;soldier_yuque&quot;</span>,
  <span class="hljs-attr">&quot;repo&quot;</span>: <span class="hljs-string">&quot;blog&quot;</span>,
  <span class="hljs-attr">&quot;token&quot;</span>: <span class="hljs-string">&quot;语雀的token&quot;</span>,
  <span class="hljs-attr">&quot;onlyPublished&quot;</span>: <span class="hljs-literal">true</span>,
  <span class="hljs-attr">&quot;onlyPublic&quot;</span>: <span class="hljs-literal">true</span>
&#125;,
  <span class="hljs-attr">&quot;dependencies&quot;</span>: &#123;
    <span class="hljs-attr">&quot;hexo&quot;</span>: <span class="hljs-string">&quot;^5.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-deployer-git&quot;</span>: <span class="hljs-string">&quot;^2.1.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-generator-archive&quot;</span>: <span class="hljs-string">&quot;^1.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-generator-category&quot;</span>: <span class="hljs-string">&quot;^1.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-generator-index&quot;</span>: <span class="hljs-string">&quot;^2.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-generator-tag&quot;</span>: <span class="hljs-string">&quot;^1.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-renderer-ejs&quot;</span>: <span class="hljs-string">&quot;^1.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-renderer-marked&quot;</span>: <span class="hljs-string">&quot;^3.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-renderer-stylus&quot;</span>: <span class="hljs-string">&quot;^2.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-server&quot;</span>: <span class="hljs-string">&quot;^2.0.0&quot;</span>,
    <span class="hljs-attr">&quot;hexo-theme-fluid&quot;</span>: <span class="hljs-string">&quot;^1.8.4&quot;</span>,
    <span class="hljs-attr">&quot;yuque-hexo&quot;</span>: <span class="hljs-string">&quot;^1.7.0&quot;</span>
  &#125;
&#125;</code></pre>
</li>
<li><p>配置 <code>.travis.yml</code></p>
 <details>
     <summary>点击展开</summary>

 <pre><code class="hljs yml"><span class="hljs-comment"># 设置语言</span>
<span class="hljs-attr">language:</span> <span class="hljs-string">node_js</span>

<span class="hljs-comment"># 设置相应的版本（必须12以上）</span>
<span class="hljs-attr">node_js:</span> 
  <span class="hljs-bullet">-</span> <span class="hljs-number">15</span>

<span class="hljs-attr">cache:</span>
  <span class="hljs-attr">apt:</span> <span class="hljs-literal">true</span>
  <span class="hljs-attr">directories:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">node_modules</span> <span class="hljs-comment"># 缓存不经常更改的内容</span>

<span class="hljs-comment"># 更改时区</span>
<span class="hljs-attr">before_install:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">export</span> <span class="hljs-string">TZ=&#x27;Asia/Shanghai&#x27;</span>

<span class="hljs-comment"># 安装hexo及插件</span>
<span class="hljs-attr">install:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">npm</span> <span class="hljs-string">install</span> <span class="hljs-string">hexo-cli</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">npm</span> <span class="hljs-string">install</span> <span class="hljs-string">yuque-hexo</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">npm</span> <span class="hljs-string">install</span>

<span class="hljs-comment"># 下拉代码后执行的操作</span>
<span class="hljs-attr">script:</span>
  <span class="hljs-comment"># 同步语雀文章到本地</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">yuque-hexo</span> <span class="hljs-string">clean</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">yuque-hexo</span> <span class="hljs-string">sync</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">hexo</span> <span class="hljs-string">generate</span> <span class="hljs-comment"># 生成</span>

<span class="hljs-attr">after_script:</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">cd</span> <span class="hljs-string">./public</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">init</span>
  <span class="hljs-comment"># 修改github的用户名</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">user.name</span> <span class="hljs-string">&quot;soldiergit&quot;</span>
  <span class="hljs-comment"># 修改email</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">user.email</span> <span class="hljs-string">&quot;soldier_wyyx@163.com&quot;</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">add</span> <span class="hljs-string">.</span>
  <span class="hljs-comment"># 提交记录包含时间 跟上面更改时区配合</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">commit</span> <span class="hljs-string">-m</span> <span class="hljs-string">&quot;Travis CI Auto Builder at `date +&quot;</span><span class="hljs-string">%Y-%m-%d</span> <span class="hljs-string">%H:%M&quot;`&quot;</span>
  <span class="hljs-comment"># Travis_Token是在Travis官网中配置环境变量的名称（more options 选择 setting添加的值）</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">--force</span> <span class="hljs-string">--quiet</span> <span class="hljs-string">&quot;https://$&#123;Github_Token&#125;@$&#123;GH_REF&#125;&quot;</span> <span class="hljs-string">master:master</span>
  <span class="hljs-comment"># 【2021.05.13】修改gitee的用户名</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">user.name</span> <span class="hljs-string">&quot;$&#123;Gitee_Username&#125;&quot;</span>
  <span class="hljs-comment"># 【2021.05.13】也提交到码云</span>
  <span class="hljs-bullet">-</span> <span class="hljs-string">git</span> <span class="hljs-string">push</span> <span class="hljs-string">--force</span> <span class="hljs-string">--quiet</span> <span class="hljs-string">https://$&#123;Gitee_Username&#125;:$&#123;Gitee_Token&#125;@$&#123;GE_REF&#125;</span> <span class="hljs-string">master:master</span>

<span class="hljs-comment"># 只监测resource分支，resource是我存放源码的分支的名称，可根据自己情况设置</span>
<span class="hljs-attr">branches:</span>
  <span class="hljs-attr">only:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">resource</span>

<span class="hljs-comment"># 配置常量</span>
<span class="hljs-attr">env:</span>
  <span class="hljs-attr">global:</span>
    <span class="hljs-comment"># 设置GH_REF，注意更改yourname及末尾加上.git</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">GH_REF:</span> <span class="hljs-string">github.com/soldiergit/soldiergit.github.io.git</span>
    <span class="hljs-comment"># 【2021.05.13】码云的</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">GE_REF:</span> <span class="hljs-string">gitee.com/soldiergitee/soldiergitee.git</span>

<span class="hljs-comment"># 配置通知（电子邮件、IRC、campfire等）</span>
<span class="hljs-comment"># https://docs.travis-ci.com/user/notifications/</span>
<span class="hljs-attr">notifications:</span>
  <span class="hljs-attr">email:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-number">583403411</span><span class="hljs-string">@qq.com</span>
    <span class="hljs-bullet">-</span> <span class="hljs-string">soldier_wyyx@163.com</span>
  <span class="hljs-attr">on_success:</span> <span class="hljs-string">change</span>
  <span class="hljs-attr">on_failure:</span> <span class="hljs-string">always</span></code></pre>
 </details>

</li>
</ol>
</li>
</ol>
<p>配置完成将其提交到你的 github 仓库。</p>
<p><font color=#FF000><strong>注意：</strong></font>语雀不要开启保存并发布，否则无法触发 webhook</p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90/">持续集成</a>
                    
                      <a class="hover-with-bg" href="/tags/Travis-ci/">Travis-ci</a>
                    
                      <a class="hover-with-bg" href="/tags/Hexo/">Hexo</a>
                    
                      <a class="hover-with-bg" href="/tags/%E8%AF%AD%E9%9B%80/">语雀</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/12/15/workplace/DCITS/">
                        <span class="hidden-mobile">西安神州数码融信软件有限公司</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://soldiergit.github.io/" target="_blank" rel="nofollow noopener"><span>Copyright © 2020 soldier Powered by Hexo Fluid Core on Kubernetes</span></a> <i class="iconfont icon-love"></i> <a href="mailto:soldier_wyyx@163.com"><span>联系我</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Travis-ci+Hexo+GithubPages搭建个人博客&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>












  
    <!-- Baidu Analytics -->
    <script defer>
      var _hmt = _hmt || [];
      (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?28d1b3a306f2b9f13ed66ffd0d5a0a9a";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  

  

  

  
    <!-- Tencent Analytics -->
    <script defer>
      var _mtac = {};
      (function () {
        var mta = document.createElement("script");
        mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
        mta.setAttribute("name", "MTAH5");
        mta.setAttribute("sid", "500732630");
        
        mta.setAttribute("cid", "500732632");
        
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(mta, s);
      })();
    </script>
  

  
    <!-- 51.la Analytics -->
    <script defer type="text/javascript" src="//js.users.51.la/20973747.js"></script>
  

  





</body>
</html>
